package com.hfy.music.service.impl;

import com.hfy.model.vo.MusicVo;
import com.hfy.music.mapper.MusicUserMapper;
import com.hfy.music.service.MusicUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import result.Result;

import java.util.List;

import static utils.MusicConverter.getMusicResult;

/**
 * @ author 韩
 * time: 2024/6/4 17:41
 */

@Service
public class MusicUserServiceImpl implements MusicUserService {

    @Autowired
    private MusicUserMapper musicInfoMapper;

    @Override
    public Result getMusicNum(Long account) {
        Integer musicNum = musicInfoMapper.getMusicNum(account);
        return Result.ok(musicNum);
    }

    @Override
    public Result getMusic(Long account) {

        if (account == null) return Result.error("账号不能为空");
        List<MusicVo> musicList = musicInfoMapper.getMusic(account);
        return getMusicResult(musicList);
    }
}
